package com.cc.test;

import com.cc.entity.EbOrder;
import com.cc.mapper.OrderMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.List;

//导入spring 的单元测试
@RunWith(SpringJUnit4ClassRunner.class)
//导入spring 的配置文件
@ContextConfiguration("classpath:xml/spring-web.xml")
public class test {
    @Autowired
    OrderMapper OrderMapper;
    //增加操作
    @Test
    public void testSave(){
        EbOrder ebOrder=new EbOrder();
        ebOrder.setEpId(300);
        ebOrder.setEoId(200);
        ebOrder.setEodQuantity(4);
        int num=OrderMapper.save(ebOrder);
        System.out.println(num);
    }

    @Test
    public void testNewsPage(){
        int page =1;//查询第1 页
        int pageSize= 3;//每页3 条
        //alt+Enter

        List<EbOrder> news = OrderMapper.listByPage((page-1) * pageSize, pageSize);
        System.out.println(news);

    }
    //更新操作
    @Test
   public void testUpdate(){
       EbOrder ebOrder=new EbOrder();
       ebOrder.setEodId(748);
       ebOrder.setEpId(300);
       ebOrder.setEoId(200);
       ebOrder.setEodQuantity(4);
       int num=OrderMapper.updateByPrimaryKey(ebOrder);
       System.out.println(num);
    }
    //删除操作
    @Test
    public void testDelete(){
        int num=OrderMapper.delete(748);
        System.out.println(num);
    }

}
